package com.ideaction.game.rank;

import org.springframework.stereotype.Component;

/**
 * @author wh
 * @create 2021-09-10 13:43
 */
@Component
public class LevelRankBoard extends AbstractRankBoard<TestPlayer> {
    
    /**
     * 排行榜类型
     *
     * @return
     */
    @Override
    protected RankBoardType getRankType() {
        return RankBoardTypeEnum.LEVEL_RANK_BOARD;
    }
    
    /**
     * 获取 {@link TestPlayer} id
     *
     * @param testPlayer
     * @return
     */
    @Override
    public String getId(TestPlayer testPlayer) {
        return testPlayer.getId();
    }
    
    /**
     * 构造排行榜对应的基本数据对象
     *
     * @param testPlayer 接收到的原始数据
     * @return
     */
    @Override
    public RankData buildRankDataFrom(TestPlayer testPlayer) {
        RankData rankData = new RankData();
        rankData.setDataId(testPlayer.getId());
        rankData.setScore(testPlayer.getLevel());
        return rankData;
    }
}